Question: I have a bag with blue marbles and yellow marbles in it. At the moment, the ratio of blue marbles to yellow marbles is 8:5. If I remove 12 blue marbles and add 21 yellow marbles, the ratio will be 1:3. How many blue marbles were in the bag before I removed some?
Let $x$ be the number of blue marbles and $y$ the number of yellow marbles before I added more. We are given that the ratio of blue to yellow is 8:5, so $\dfrac{x}{y}=\dfrac{8}{5}$. Additionally, after we remove blue marbles and add yellow marbles the total number of blue marbles and yellow marbles will be $x-12$ and $y+21$ respectively. We're given that at this point the ratio will be $1:3$, so $\dfrac{x-12}{y+21}=\dfrac{1}{3}$. Cross multiplying the first equation gives $5x=8y$ and cross multiplying the second gives $3(x-12)=1(y+21)$. Solving two linear equations on two variables is routine; we get the solution $y=15$, $x=24$. Since $x$ represents the number of blue marbles before some were removed, the answer to the problem is just $\boxed{24}$.